import java.util.Arrays;

/**
 * @ClassName NumSum
 * @Description 两数之和
 * @Author 李明忠
 * @Date 2025/5/20 21:27
 * @Version 1.0
 */
public class NumSum {
    private static int[] numSum(int[] arr, int target) {
        int[] indexs = new int[2];
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length; j++) {
                if (i != j && arr[i] + arr[j] == target) {
                    indexs[0] = i;
                    indexs[1] = j;
                    return indexs;
                }
            }
        }
        return null;
    }
    public static void main(String[] args) {
        int[] arr = {2,7,11,15};
        int target = 9;
        int[] indexs = numSum(arr, target);
        System.out.println(Arrays.toString(indexs));
    }
}
